package com.jeecms.wicool.dao.car.impl;


import org.springframework.stereotype.Repository;
import com.jeecms.common.hibernate3.Finder;
import com.jeecms.common.hibernate3.HibernateBaseDao;
import com.jeecms.common.page.Pagination;
import com.jeecms.wicool.dao.car.CarParamDao;
import com.jeecms.wicool.entity.car.CarParam;

@Repository
public class CarParamDaoImpl extends HibernateBaseDao<CarParam, Integer>
		implements CarParamDao {

	@Override
	protected Class<CarParam> getEntityClass() {
		// TODO Auto-generated method stub
		return CarParam.class;
	}
	@Override
	public Pagination getPage(Integer carTypeId,
			int pageNo, int pageSize) {
			Finder f = Finder.create("select bean from CarParam bean where 1=1 ");
			
			if (null!=carTypeId){
				f.append(" and bean.carType.id = :carTypeId");
				f.setParam("carTypeId",carTypeId);
			}
			f.append(" order by bean.id desc");
			return find(f, pageNo, pageSize);
	}
	@Override
	public CarParam findById(Integer id) {
		CarParam entity = get(id);
		return entity;
	}
	@Override
	public CarParam save(CarParam bean) {
		getSession().save(bean);
		return bean;
	}
	@Override
	public CarParam deleteById(Integer id) {
		CarParam entity = super.get(id);
		if (entity != null) {
			getSession().delete(entity);
		}
		return entity;
	}
}